package com.zhuiyun.pm.utils;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.connection.Message;
import org.springframework.data.redis.listener.KeyExpirationEventMessageListener;
import org.springframework.data.redis.listener.RedisMessageListenerContainer;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

/**
* @Author G胖
* @Description 监听redis 过期key操作
* @Date 2022-09-21 上午 11:44
* @Return

*/
@Component
@Transactional
public class RedisKeyExpirationListener extends KeyExpirationEventMessageListener {

    @Autowired
    RedisUtil redisUtil;

    public RedisKeyExpirationListener(RedisMessageListenerContainer listenerContainer) {
        super(listenerContainer);
    }

    /**
     * 监听redis过期key
     * @param message
     * @param pattern
     */
    @Override
    public void onMessage(Message message, byte[] pattern) {
        String sId = message.toString();
    }
}
